package cn.lili.controller.system.goods_auth;

import cn.lili.common.utils.ResultUtil;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.goods_auth.service.GoodsAuthSpaceService;
import cn.lili.modules.system.entity.dos.LiAuthSpace;
import cn.lili.modules.system.entity.dto.AuthSpaceSearchParams;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@Api(tags = "空间管理")
@RequestMapping("/system/auth_space")
public class GoodsAuthSpaceController {

    @Resource
    private GoodsAuthSpaceService goodsAuthSpaceService;

    @ApiModelProperty(value = "空间分页列表")
    @GetMapping("/page")
    public ResultMessage<Object> spacePage(AuthSpaceSearchParams searchParams){
        return ResultUtil.data(goodsAuthSpaceService.spacePage(searchParams));
    }

    @ApiModelProperty(value = "添加空间")
    @PostMapping("/add")
    public ResultMessage<Object> addSpace(@RequestBody LiAuthSpace authSpace){
        return ResultUtil.data(goodsAuthSpaceService.addSpace(authSpace));
    }

    @ApiModelProperty(value = "删除空间")
    @DeleteMapping("/del")
    public ResultMessage<Object> deleteSpace(@RequestParam String id){
        return ResultUtil.data(goodsAuthSpaceService.deleteSpace(id));
    }

    @ApiModelProperty(value = "修改空间")
    @PutMapping("/update")
    public ResultMessage<Object> updateSpace(@RequestBody LiAuthSpace authSpace){
        return ResultUtil.data(goodsAuthSpaceService.updateSpace(authSpace));
    }
}
